package org.geeks.gsredisson.conf;

import org.redisson.api.RedissonClient;
import org.redisson.codec.JsonJacksonCodec;
import org.redisson.codec.KryoCodec;
import org.redisson.spring.cache.RedissonSpringCacheManager;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.cache.CacheManager;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class CacheConfig {

  @Autowired private RedissonClient redissonClient;

  @Bean
  public CacheManager cacheManager() {
    RedissonSpringCacheManager redissonSpringCacheManager =
        new RedissonSpringCacheManager(redissonClient);
    redissonSpringCacheManager.setCodec(new KryoCodec());

    return redissonSpringCacheManager;
  }
}
